<%@ page import="wang.bean.Theme" %>
<%@ page import="wang.dao.ThemeDao" %>
<%@ page import="java.util.List" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<jsp:include page="css.jsp"/>
<style lang="css">
    .admin-tourist-attraction-header {
        height: 60px;
        background-color: #1fc8db;
        background-image: linear-gradient(141deg, #9fb8ad 0%, #1fc8db 51%, #2cb5e8 75%);
    }

    .white-text {
        color: white;
    }
</style>

<%
    ThemeDao themeDao = new ThemeDao();
    List<Theme> themes = themeDao.list();
    session.setAttribute("themes", themes);
%>
<div class="admin-tourist-attraction-header container-fluid">
    <div class="row">
        <div class="col-md-12">
            <nav id="nav" class="navbar navbar-expand-lg">
                <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                    <span class="navbar-toggler-icon"></span>
                </button>
                <a class="navbar-brand white-text" href="admin_tourist_attraction.jsp">猫途鹰旅游-管理端</a>
                <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                    <form id="search-form" class="form-inline" action="list.attraction" style="margin: auto 0">
                        <input class="form-control mr-sm-2" type="text" name="title"/>
                        <select class="form-control mr-sm-2 form-control-placeholder" name="theme">
                            <option value="" disabled selected hidden>请选择</option>
                            <c:if test="${!empty themes}">
                                <c:forEach items="${themes}" var="theme" varStatus="vs">
                                    <option value="${theme.name}" style="color: black">${theme.name}</option>
                                </c:forEach>
                            </c:if>
                        </select>
                        <button class="btn btn-dark my-2 my-sm-0" type="submit" style="margin-right: 8px">
                            <i class="bi bi-search"></i>
                        </button>
                        <button class="btn btn-outline-light my-2 my-sm-0" type="button" onclick="resetSearchForm()">
                            <i class="bi bi-x-circle"></i>
                        </button>
                    </form>
                    <ul class="navbar-nav ml-md-auto">
                        <li class="nav-item white-text active">
                            <a class="nav-link"> <c:if test="${! empty admin}"> ${admin.name} </c:if></a>
                        </li>
                        <li class="nav-item active">
                            <a class="nav-link btn btn-outline-light my-2 my-sm-0" href="logout.admin">
                                <i class="bi bi-box-arrow-left"></i>
                            </a>
                        </li>
                    </ul>
                </div>
            </nav>
        </div>
    </div>
</div>

<script type="text/javascript">
    // $(document).ready(function () {
    //     $("#search-form").submit();
    // });

    function resetSearchForm() {
        document.getElementById("search-form").reset();
        $("#search-form").submit();
    }
</script>